package cn.silver.module.monitor.domain;

import cn.silver.framework.core.utils.DateUtils;
import cn.silver.framework.mybatis.annotation.Table;
import cn.silver.framework.mybatis.annotation.TableField;
import cn.silver.framework.mybatis.enums.SearchEnums;
import cn.silver.framework.mybatis.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author zhouxiaobo
 */
@Data
@NoArgsConstructor
@Table(name = "log_login")
@EqualsAndHashCode(callSuper = true)
@Schema(name = "LogLogin", title = "系统访问记录", description = "")
public class LogLogin extends BaseEntity {

    /**
     * 用户主键
     */
    @Schema(title = "用户主键")
    private String userId;

    /**
     * 登录账号
     */
    @Schema(title = "登录账号")
    @TableField(name = "user_code", searchType = SearchEnums.LIKE)
    private String userCode;

    /**
     * 用户姓名
     */
    @Schema(title = "用户姓名")
    @TableField(name = "user_name", searchType = SearchEnums.LIKE)
    private String userName;

    /**
     * 客户端编码
     */
    @Schema(title = "客户端编码")
    @TableField(name = "client_code", searchType = SearchEnums.EQ)
    private String clientCode;

    /**
     * 授权类型
     */
    @Schema(title = "授权类型")
    @TableField(name = "grant_type", searchType = SearchEnums.EQ)
    private String grantType;

    /**
     * 设备类型
     */
    @Schema(title = "设备类型")
    @TableField(name = "device_type", searchType = SearchEnums.EQ)
    private String deviceType;

    /**
     * 操作系统
     */
    @Schema(title = "操作系统")
    private String os;

    /**
     * 登录IP地址
     */
    @Schema(title = "登录IP地址")
    private String ipaddr;

    /**
     * 登录结果
     */
    @Schema(title = "登录结果")
    @TableField(name = "result", searchType = SearchEnums.EQ)
    private String result;

    /**
     * 提示消息
     */
    @Schema(title = "提示消息")
    private String message;

    /**
     * 访问时间
     */
    @Schema(title = "访问时间")
    @TableField(name = "login_time", searchType = SearchEnums.BETWEEN)
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD_HH_MM_SS)
    private Date loginTime;

    /**
     * 租户编号
     */
    @Schema(title = "租户编号")
    @TableField(name = "tenant_id", searchType = SearchEnums.EQ)
    private String tenantId;
}
